<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="contextPath" value="${pageContext.request.contextPath}"></c:set>
<link rel="stylesheet" type="text/css" href="${contextPath}/resources/easyui/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="${contextPath}/resources/easyui/themes/bootstrap/window.css">
<link rel="stylesheet" type="text/css" href="${contextPath}/resources/easyui/themes/icon.css">
<style>
td{
width: auto;
}
.app.detalis .title{
     background:#fafafa;
     border:1px solid #ddd;
     border-width:1px 0;
}
font.word-color{
     color:#6F6F6F;
}
h5.title-color{
     margin:0;
     text-align:left
}
</style>
<script type="text/javascript" src="${contextPath}/resources/easyui/jquery.min.js"></script>
<script type="text/javascript" src="${contextPath}/resources/easyui/commen.js"></script>
<script type="text/javascript" src="${contextPath}/resources/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${contextPath}/resources/easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="${contextPath}/resources/easyui/jquery.form.js"></script>
<script type="text/javascript" src="${contextPath}/resources/easyui/mask.js"></script>
<script type="text/javascript">
$(function(){
	
}) 

/* 搜索应用 */
function search_(){
	var $appName = $("#_app_name").val();
	var status = $('#_status').combobox('getValue');
	if($appName.length>60){
    	$.messager.alert('提示',"应用名称不能超过60个字符!",'warning');
    	return false;
	}
	$appName = encodeURI(encodeURI($appName));
	$("#dg").datagrid('load', {
		appName:$appName,
		status:status
	});
}

$(function(){
	$("#dg").datagrid({
		url : '${pageContext.request.contextPath}/sys/app/findapps.do',
		queryParams: {
			appName:"",
			status:-1
		},
		singleSelect : false,
		pagination:true,
		rownbmers : true,
		autoRowHeight : false,
		checkOnSelect: true, 
		selectOnCheck: true,
		toolbar:'#tb',
		sortName:'createDate',
		sortOrder:'desc', 
		columns : [[
		            {
		            	field : 'appId',
		            	title : 'ID',
		            	width : '100',
		            	align : 'center',
		            	hidden : true
		            },{
		            	field : 'ck',
		            	title : '全选',
		            	width : '100',
		            	align : 'center',
		            	checkbox : true,
		            	formatter : function(value,rowData,rowIndex){
		            		return "<input type='checkbox' value='" + rowData.id + "' >";;
		            	}
		            },{
		            	field : 'appName',
		            	title : '应用名称',
		            	width : '200',
		            	align : 'center',
		            	sortable: false,
		            	formatter : function(value,rowData,rowIndex){
                            return init.$Reg_Length(value,rowData);
		            	}
		            },{
		            	field : 'appPlatform',
		            	title : '应用平台',
		            	width : '200',
		            	align : 'center',
		            	sortable: false,
		            	formatter : function(value,rowData,rowIndex){
		            		return init.$Reg_Length(value,rowData);
		            	}
		            },{
		            	field : 'appProfile',
		            	title : '应用简介',
		            	width : '200',
		            	align : 'center',
		            	sortable: false,
		            	formatter : function(value,rowData,rowIndex){
		            		return init.$Reg_Length(value,rowData);
		            	}
		            },{
		            	field : 'appDescribe',
		            	title : '应用介绍',
		            	width : '200',
		            	align : 'center',
		            	sortable: false,
		            	formatter : function(value,rowData,rowIndex){
		            		return init.$Reg_Length(value,rowData);
		            	}
		            },{
		            	field : 'webName',
		            	title : '网站名称',
		            	width : '200',
		            	align : 'center',
		            	sortable: false,
		            	formatter : function(value,rowData,rowIndex){
		            		return init.$Reg_Length(value,rowData);
		            	}
		            },{
		            	field : 'webDomains',
		            	title : '网站域名',
		            	width : '150',
		            	align : 'center',
		            	sortable: false,
		            	formatter : function(value,rowData,rowIndex){
		            		return init.$Reg_Length(value,rowData);
		            	}
		            },{
		            	field : 'webRecord',
		            	title : '网站备案',
		            	width : '150',
		            	align : 'center',
		            	sortable: false,
		            	formatter : function(value,rowData,rowIndex){
		            		return init.$Reg_Length(value,rowData);
		            	}
		            },{
		            	field : 'status',
		            	title : '审核状态',
		            	width : '60',
		            	align : 'center',
		            	sortable: false,
		            	formatter : function(value,rowData,rowIndex){
		            		if(value==0){
		            			return "待审核";
		            		}else if(value==1){
		            			return "未通过";
		            		}else if(value==2){
		            			return "已通过";
		            		}else if(value==3){
		            			return "已冻结";
		            		}else if(value==4){
		            			return "审核中";
		            		}
                            
		            	}
		            },{
		            	field : 'createDate',
		            	title : '创建日期',
		            	width : '150',
		            	align : 'center',
		            	sortable: false
		            },{
		            	field : 'cz',
		            	title : '操作',
		            	width : '150',
		            	align : 'center',
		            	sortable: false,
		            	formatter : function(value,rowData,rowIndex){
		            		var status = rowData.status;
		            		if(status==0){
		            			return "<a href='javascript:modify($(\"#dg\"),"+rowData.appId+",2,\"${contextPath}/sys/app/updateappstatus.do\",\"应用/网站\")'>通过</a> |"+ 
		            			" <a href='javascript:modify($(\"#dg\"),"+rowData.appId+",1,\"${contextPath}/sys/app/updateappstatus.do\",\"应用/网站\")'>未通过</a> |"+
		            			" <a href='javascript:modify($(\"#dg\"),"+rowData.appId+",3,\"${contextPath}/sys/app/updateappstatus.do\",\"应用/网站\")'>冻结</a>";
		            		}else if(status==1){
		            			return "<a href='javascript:modify($(\"#dg\"),"+rowData.appId+",2,\"${contextPath}/sys/app/updateappstatus.do\",\"应用/网站\")'>通过</a> |"+
		            			"<font color='gray'>未通过</font> | "+
		            			" <a href='javascript:modify($(\"#dg\"),"+rowData.appId+",3,\"${contextPath}/sys/app/updateappstatus.do\",\"应用/网站\")'>冻结</a>";
		            		}else if(status==2){
		            			return "<font color='gray'>通过</font> | "+
		            			" <a href='javascript:modify($(\"#dg\"),"+rowData.appId+",1,\"${contextPath}/sys/app/updateappstatus.do\",\"应用/网站\")'>未通过</a> |"+
		            			" <a href='javascript:modify($(\"#dg\"),"+rowData.appId+",3,\"${contextPath}/sys/app/updateappstatus.do\",\"应用/网站\")'>冻结</a>";
		            		}else if(status==3){
		            			return "<font color='gray'>通过</font> | <font color='gray'>未通过</font> | "+
		            			" <a href='javascript:modify($(\"#dg\"),"+rowData.appId+",2,\"${contextPath}/sys/app/updateappstatus.do\",\"应用/网站\")'>启用</a>";
		            		}
		            	}
		            }
		            ]],
		            pagination : true,
		            pageList : [10,20,30,40,50,60],
		            pageSize : 10,
		            onLoadSuccess : function(data){
		            },
		            rowStyler: function(index,row){
	                }
	})
})

var init = {
	$Reg_Length : function(param,$rowData){
		var value;
		value = decodeURI(param);
		value = decodeURI(value);
		var o = value;
		if(null==value||""==value){
			value = "-";
		}else if(value.length>10){
			value = value.substring(0,9)+"...";
		}else{
			value = value;
		}
		var str;
		str = JSON.stringify($rowData);
		str = str.replace(/\"/ig,"<@>"); 
        return  '<a href="javascript:;" onclick="init.$Show_APP_Details(\''+str+'\');" title="'+o+'">'+value+'</a>';
	},
	$Show_APP_Details : function(param){
		param = param.replace(/<@>/ig,"\"");
		var obj = eval("("+param+")");
		$.ajax({
    		url : "${pageContext.request.contextPath}/sys/app/findcooperinfo.do",
    		cache : false,
    		type  :'post',
    		data : {
    			appId : obj.appId
    			},
    		dataType : 'json',
    		success : function(data){
        		if(null!=data&&""!=data){
        			var tag;
        			if(obj.appName==null||obj.appName==""){
        				tag = 2;
        			}else{
        				tag = "";
        			}
        			$("#_c_legal_person_name"+tag).html(data.legalPersonName);
        			$("#_c_legal_person_phone"+tag).html(data.legalPersonPhone);
        			$("#_c_id_card"+tag).html(data.idCard);
        			$("#legal_img"+tag).html('<img src="'+data.idCardImgFrontURL+'" width="120px;" height="80px;"><img src="'+data.idCardImgBackURL+'" width="120px;" height="80px;">');
        			$("#_c_organization"+tag).html(data.organization);
        			$("#_c_license_number"+tag).html(data.licenseNumber);
        			$("#license_img"+tag).html('<img src="'+data.licenseImgFrontURL+'" width="120px;" height="80px;"><img src="'+data.licenseImgBackURL+'" width="120px;" height="80px;">');
        		}
    		}
    	})
		if(obj.appName==null||obj.appName==""){
			$("#_web_name_").html(obj.webName);
			$("#_web_domains").html(obj.webDomains);
			$("#_web_record").html(obj.webRecord);
			$("#_t_createdate2").html(obj.createDate);
			mask($('#dlg2'));
			$('#dlg2').dialog('open');
		}else{
			$("#_app_name_").html(obj.appName);
			$("#_app_platform").html(obj.appPlatform);
			$("#_app_profile").html(obj.appProfile);
			$("#_app_describe").html(obj.appDescribe);
			$("#_t_createdate").html(obj.createDate);
			mask($('#dlg'));
			$('#dlg').dialog('open');
		}
	}
	
}
</script>
<table id="dg" title="" style="width: 100%;"></table>
<div id="tb" style="padding: 0px 0px;">
<fieldset>
<legend>查询条件</legend>
     &nbsp;&nbsp;应用名称/网站名称: <input class="easyui-textbox" style="width: 120px" id="_app_name">
     &nbsp;&nbsp;审核状态： <select id="_status" editable="false" class="easyui-combobox"
			panelHeight="auto" style="width: 100px">
			<option value="-1">--所有状态--</option>
			<option value="0">待审核</option>
			<option value="1">未通过</option>
			<option value="2">已通过</option>
			<option value="3">已冻结</option>
			<option value="4">审核中</option>
		</select> 
	 &nbsp;&nbsp;<a href="javascript:;" class="easyui-linkbutton"
		iconCls="icon-search" onclick="search_();">Search</a><br /><br/>
</fieldset>
<div id="ft">
			<a href="javascript:void(0)" class="easyui-linkbutton"
				iconCls="icon-remove" plain="true" onclick="destroyMutiles($('#dg'),'${contextPath}/sys/app/updateappstatus.do','应用/网站',3)">批量冻结</a>
				<a href="javascript:void(0)" class="easyui-linkbutton"
				iconCls="icon-remove" plain="true" onclick="destroyMutiles($('#dg'),'${contextPath}/sys/app/updateappstatus.do','应用/网站',2)">批量审核</a>
		</div>
</div>
<div id = "dlg" class="easyui-dialog" title="应用信息" style="width:75%;height:500px;max-width:1680px;padding:10px" data-options="
            iconCls:'icon-save',
            onResize:function(){
                $(this).dialog('center');
            },
            closed:true">
     <div class="easyui-panel" style="width:100%;height: 100%;">
        <div class="easyui-layout" data-options="fit:true">
               <div class="easyui-layout" data-options="fit:true">
            <div data-options="region:'west',split:true" style="width:50%;padding:10px">
                <table cellpadding="5" class="app detalis">
                <tr>
                    <td><b>应用详情：</b></td>
                </tr>
                <tr class="title">
                    <td><h5 class="title-color">应用名:</h5></td>
                </tr>
                <tr>
                    <td><font class="word-color" ><label id="_app_name_"></label></font></td>
                </tr>
                <tr class="title">
                    <td><h5 class="title-color">应用平台:</h5></td>
                </tr>
                <tr>
                    <td><font class="word-color"><label id="_app_platform"></label></font></td>
                </tr>
                <tr class="title">
                    <td><h5 class="title-color">应用简介:</h5></td>
                </tr>
                <tr>
                    <td><font class="word-color"><label id="_app_profile"></label></font></td>
                </tr>
                <tr class="title">
                    <td><h5 class="title-color">应用介绍:</h5></td>
                </tr>
                <tr>
                    <td><font class="word-color"><label id="_app_describe"></label></font></td>
                </tr>
                <tr class="title">
                    <td><h5 class="title-color">创建日期:</h5></td>
                </tr>
                <tr>
                    <td><font class="word-color"><label id="_t_createdate"></label></font></td>
                </tr>
                </table>
            </div>           
            <div data-options="region:'center',split:true" style="width:50%;padding:10px">
                <table cellpadding="5" class="app detalis">
                <tr>
                    <td><b>合作者资历信息：</b></td>
                </tr>
                <tr class="title">
                    <td><h5 class="title-color">法定人姓名:</h5></td>
                    <td><font class="word-color" ><label id="_c_legal_person_name"></label></font></td>
                    <td><h5 class="title-color">法定人手机号:</h5></td>
                    <td><font class="word-color" ><label id="_c_legal_person_phone"></label></font></td>
                </tr>
                <tr class="title">
                    <td colspan="4"><h5 class="title-color">法定人身份证号码:</h5></td>
                </tr>
                <tr>
                    <td colspan="4"><font class="word-color" ><label id="_c_id_card"></label></font></td>
                </tr>
                <tr class="title">
                    <td colspan="4"><h5 class="title-color">法定人身份证:</h5></td>
                </tr>
                <tr>
                    <td colspan="4"><div id="legal_img"></div></td>
                </tr>
                <tr class="title">
                    <td><h5 class="title-color">组织结构名称:</h5></td>
                    <td><font class="word-color" ><label id="_c_organization"></label></font></td>
                    <td><h5 class="title-color">营业执照号码:</h5></td>
                    <td><font class="word-color"><label id="_c_license_number"></label></font></td>
                </tr>
                <tr class="title">
                    <td colspan="4"><h5 class="title-color">营业执照:</h5></td>
                </tr>
                <tr>
                    <td colspan="4"><div id="license_img"></div></td>
                </tr>
                </table>
            </div>
        </div>
        </div>
    </div>
</div>
<div id = "dlg2" class="easyui-dialog" title="网站信息" style="width:75%;height:500px;max-width:1680px;padding:10px" data-options="
            iconCls:'icon-save',
            onResize:function(){
                $(this).dialog('center');
            },
            closed:true">
    <div class="easyui-panel" style="width:100%;height: 100%;">
        <div class="easyui-layout" data-options="fit:true">
               <div class="easyui-layout" data-options="fit:true">
            <div data-options="region:'west',split:true" style="width:50%;padding:10px">
                <table cellpadding="5" class="app detalis">
                <tr>
                    <td><b>网站详情：</b></td>
                </tr>
                <tr class="title">
                    <td><h5 class="title-color">网站名:</h5></td>
                </tr>
                <tr>
                    <td><font class="word-color" ><label id="_web_name_"></label></font></td>
                </tr>
                <tr class="title">
                    <td><h5 class="title-color">网站域名:</h5></td>
                </tr>
                <tr>
                    <td><font class="word-color"><label id="_web_domains"></label></font></td>
                </tr>
                <tr class="title">
                    <td><h5 class="title-color">网站备案:</h5></td>
                </tr>
                <tr>
                    <td><font class="word-color"><label id="_web_record"></label></font></td>
                </tr>
                <tr class="title">
                    <td><h5 class="title-color">创建日期:</h5></td>
                </tr>
                <tr>
                    <td><font class="word-color"><label id="_t_createdate2"></label></font></td>
                </tr>
                </table>
            </div>
            <div data-options="region:'center',split:true" style="width:50%;padding:10px">
                <table cellpadding="5" class="app detalis">
                <tr>
                    <td><b>合作者资历信息：</b></td>
                </tr>
                <tr class="title">
                    <td><h5 class="title-color">法定人姓名:</h5></td>
                    <td><font class="word-color" ><label id="_c_legal_person_name2"></label></font></td>
                    <td><h5 class="title-color">法定人手机号:</h5></td>
                    <td><font class="word-color" ><label id="_c_legal_person_phone2"></label></font></td>
                </tr>
                <tr class="title">
                    <td colspan="4"><h5 class="title-color">法定人身份证号码:</h5></td>
                </tr>
                <tr>
                    <td colspan="4"><font class="word-color" ><label id="_c_id_card2"></label></font></td>
                </tr>
                <tr class="title">
                    <td colspan="4"><h5 class="title-color">法定人身份证:</h5></td>
                </tr>
                <tr>
                    <td colspan="4"><div id="legal_img2"></div></td>
                </tr>
                <tr class="title">
                    <td><h5 class="title-color">组织结构名称:</h5></td>
                    <td><font class="word-color" ><label id="_c_organization2"></label></font></td>
                    <td><h5 class="title-color">营业执照号码:</h5></td>
                    <td><font class="word-color"><label id="_c_license_number2"></label></font></td>
                </tr>
                <tr class="title">
                    <td colspan="4"><h5 class="title-color">营业执照:</h5></td>
                </tr>
                <tr>
                    <td colspan="4"><div id="license_img2"></div></td>
                </tr>
                </table>
            </div>
            </div>
            </div>
            </div>
</div>